﻿using System;

namespace RaceList.Admin.Relay
{
    public partial class CycleAdd : System.Web.UI.Page
    {
        ipowdb_suibian_webDataContext db = ConnHelper.ipowdb_suibian_web();


        /// <summary>
        /// 保存信息
        /// </summary>
        /// <para nae="sender"></para>
        /// <para nae="e"></para>
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string Message = string.Empty;
            Activity_Cycle cycle = new Activity_Cycle
            {
                addTime = DateTime.Now,
                editTime = DateTime.Now,
                startDate = Convert.ToDateTime((string) txtStartDate.Text.Trim()),
                endDate = Convert.ToDateTime((string) txtEndDate.Text.Trim()),
                status = CommonHelp.GetStatus(ddl1.SelectedIndex),
                title = txtTitle.Text.Trim(),
            };
            try
            {
                db.Activity_Cycle.InsertOnSubmit(cycle);
                db.SubmitChanges();

                var url = "http://" + Request.Url.Authority + "/activity/relay/relayindex.aspx?cycle=";
                cycle.url = url + cycle.Id;
                db.SubmitChanges();

                StringHelper.Alert(this, "活动发布成功！", "CycleList.aspx");
            }
            catch (Exception ex)
            {
                this.Message.Text = "发布失败! 失败原因：" + ex.Message + "。详细错误信息请查看错误日志。";
            }
        }
    }
}